//
//  LCHomeLendStrategyView.m
//  LendCash
//
//  Created by Mac mini on 2018/5/24.
//  Copyright © 2018年 zt. All rights reserved.
//

#import "LCHomeLendStrategyView.h"

@implementation LCHomeLendStrategyView


-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(10, 5, 100, 20)];
        lab.text = @"攻略攻略";
        lab.font = [UIFont  systemFontOfSize:17];
        [self addSubview:lab];
        
        UIButton *strategyButton = [self createButtonWithFrame:CGRectMake(frame.size.width-100, 5, 90, 20) andTitle:@"更多攻略>" andFont:MIDDLE_FONT];
        [strategyButton setTag:strategy_more];
        [self addSubview:strategyButton];
        
         UIButton *strategyOne = [self createButtonWithFrame:CGRectMake(10, 30, frame.size.width, 20) andTitle:@"如何快速借款？" andFont:BASE_FONT];
        [strategyOne setTag:strategy_first];
        [self addSubview:strategyOne];
        
         UIButton *stragegyTwo = [self createButtonWithFrame:CGRectMake(10, 60, frame.size.width, 20) andTitle:@"如何快速提升额度？" andFont:BASE_FONT];
        [stragegyTwo setTag:strategy_second];
        [self addSubview:stragegyTwo];
        
    }
    return self;
}

-(void)click:(UIButton *)button{
    if (self.lendStrategyViewCallBack) {
        self.lendStrategyViewCallBack(button.tag);
    }
}

-(UIButton *)createButtonWithFrame:(CGRect)frame andTitle:(NSString *)title andFont:(UIFont *)font{
    UIButton *button = [[UIButton alloc]initWithFrame:frame];
    [button setBackgroundColor:[UIColor clearColor]];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button setTitle:title forState:UIControlStateNormal];
    button.titleLabel.font = font;
    button.layer.cornerRadius = 5;
    [button addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    
//    button.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
    return button;
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
